<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改商品</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="umeditor/third-party/jquery.min.js"></script>
    <script type="text/javascript" src="umeditor/third-party/template.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="umeditor/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="umeditor/umeditor.min.js"></script>
    <script type="text/javascript" src="umeditor/lang/zh-cn/zh-cn.js"></script>
    <style type="text/css">
        h1{
            font-family: "微软雅黑";
            font-weight: normal;
        }
        .btn {
            display: inline-block;
            *display: inline;
            padding: 4px 12px;
            margin-bottom: 0;
            *margin-left: .3em;
            font-size: 14px;
            line-height: 20px;
            color: #333333;
            text-align: center;
            text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
            vertical-align: middle;
            cursor: pointer;
            background-color: #f5f5f5;
            *background-color: #e6e6e6;
            background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
            background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
            background-repeat: repeat-x;
            border: 1px solid #cccccc;
            *border: 0;
            border-color: #e6e6e6 #e6e6e6 #bfbfbf;
            border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
            border-bottom-color: #b3b3b3;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            border-radius: 4px;
            filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
            filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
            *zoom: 1;
            -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .btn:hover,
        .btn:focus,
        .btn:active,
        .btn.active,
        .btn.disabled,
        .btn[disabled] {
            color: #333333;
            background-color: #e6e6e6;
            *background-color: #d9d9d9;
        }

        .btn:active,
        .btn.active {
            background-color: #cccccc \9;
        }

        .btn:first-child {
            *margin-left: 0;
        }

        .btn:hover,
        .btn:focus {
            color: #333333;
            text-decoration: none;
            background-position: 0 -15px;
            -webkit-transition: background-position 0.1s linear;
            -moz-transition: background-position 0.1s linear;
            -o-transition: background-position 0.1s linear;
            transition: background-position 0.1s linear;
        }

        .btn:focus {
            outline: thin dotted #333;
            outline: 5px auto -webkit-focus-ring-color;
            outline-offset: -2px;
        }

        .btn.active,
        .btn:active {
            background-image: none;
            outline: 0;
            -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .btn.disabled,
        .btn[disabled] {
            cursor: default;
            background-image: none;
            opacity: 0.65;
            filter: alpha(opacity=65);
            -webkit-box-shadow: none;
            -moz-box-shadow: none;
            box-shadow: none;
        }
    </style>
	<link rel="stylesheet" type="text/css" href="css/add_goods.css">
	<script type="text/javascript">
		
		
		/* 校验  */
		function losefocus1(){
		
			if(document.getElementById("nameId").value==""){
				document.getElementById("null_span1").innerText="文章名不能为空";
			}
				
		}
	    function getfocus1(){
		
			
			document.getElementById("null_span1").innerText="";
			
				
		}	
		function losefocus2(){
		
			if(document.getElementById("authorId").value==""){
				document.getElementById("null_span2").innerText="作者不能为空";
			}
				
		}
	    function getfocus2(){
		
			
			document.getElementById("null_span2").innerText="";
			
				
		}	
		function losefocus3(){
		
			if(document.getElementById("scanId").value==""){
				document.getElementById("null_span3").innerText="简介不能为空";
			}
				
		}
	    function getfocus3(){
		
			
			document.getElementById("null_span3").innerText="";
			
				
		}
		function losefocus4(){
		
			if(UE.getEditor("isSjId").getContent() .value==""){
				document.getElementById("null_span4").innerText="上架状态不能为空";
			}
				
		}
	    function getfocus4(){
		
			
			document.getElementById("null_span4").innerText="";
			
				
		}	
		
		function losefocus5(){
		
			if(document.getElementById("s1Id").value==""){
				document.getElementById("null_span5").innerText="轮番图简介一不能为空";
			}
				
		}
	    function getfocus5(){
					
			document.getElementById("null_span5").innerText="";
				
		}	
		
		function losefocus6(){
		
			if(document.getElementById("s2Id").value==""){
				document.getElementById("null_span6").innerText="轮番图简介二不能为空";
			}
				
		}
	    function getfocus6(){
					
			document.getElementById("null_span6").innerText="";
				
		}	
		function jiaoyan_all(){
			var bol=true;
			if(document.getElementById("nameId").value==""){
				bol=false;
				alert("文章名不能为空");
			}else if(document.getElementById("authorId").value==""){
				bol=false;
				alert("作者不能为空");
			}else if(document.getElementById("scanId").value==""){
				bol=false;
				alert("简介不能为空");
			}else if(document.getElementById("isSjId").value==""){
				bol=false;
				alert("上架状态不能为空");
			}else if(document.getElementById("s1Id").value==""){
				bol=false;
				alert("轮番图简介一不能为空");
			}else if(document.getElementById("s2Id").value==""){
				bol=false;
				alert("轮番图简介二不能为空");
			}else if(UM.getEditor('myEditor').getContent()==""){
				bol=false;
				alert("文章内容不能为空");
			}
			return bol;
		}
		
		function success() {
			alert("更新成功");
		
		}
	function loadsecond(){
    	var req = new XMLHttpRequest();
		var second = document.getElementById("second");
		req.onreadystatechange= function(){
			if(req.readyState==4){
				var info = req.responseText;
				var infos=info.split("@@@");
				for(var i = 0;i<infos.length;i++){
					if(infos[i]!=""){
						var name = infos[i];
						var newOPtion = document.createElement("option");
						newOPtion.value=name;
						newOPtion.innerHTML=name;
						second.appendChild(newOPtion);
					}
				}
			}
		};
		req.open("post", "LoadSecond.do", true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send();
    }
    function addposition(){
		var first=document.getElementById("first").value;
		var second=document.getElementById("second").value;
		var bankuai=document.getElementById("bankuai");
		bankuai.value=bankuai.value+"("+first+","+second+")";
		
	}
	</script>


  </head>
  
  <body>
  	<!--总div  -->
     <div class="div_all">
     
     	<%-- <div class="div_1">
     			<div style="position: absolute;">
			<c:if test="${username1!=null}">
				<span style="color:red;">用户名: ${username1}</span>
			</c:if>
			<c:if test="${username1==null}">
				<a href="qiehuanUser.do" style="text-decoration: none;color:red;">亲，请登入</a>
			</c:if></div>
			<!-- <div class="div_menu">
				<a href="add_goods_showtype.do" class="a_menu">添加商品 </a>
  				<a href="show_goods.do" class="a_menu">查询商品 </a>
  				<a href="add_type.do" class="a_menu">类别管理 </a>
  				<a href="show_ads.do" class="a_menu">广告维护 </a>
  				<a href="zhuce.jsp" class="a_menu">注册账号 </a>
  				<a href="qiehuanUser.do" class="a_menu">切换账号 </a>
  				<a href="select_orders.do" class="a_menu">订单查询 </a>
  				<a href="go_tongji.do" class="a_menu">销售统计 </a>
			</div> -->
  						
     		</div>
     	</div> --%>
     	
     	<div class="div_2">
     		<!-- 添加div -->
     		<div class="div_add" style="width:800px;height:1000px;">
	     		<form action="update_article.do" method="post" enctype="multipart/form-data" onsubmit="return jiaoyan_all()" >
	     		
	     			<!-- 名称 -->
	     			<div style="margin-top:30px;">文章名称:<input value="${Article.name}" type="text" name="name" id="nameId" onblur="losefocus1()" onfocus="getfocus1()"/><br/><span class="jiaoyan" id="null_span1"></span></div>	 
	     			<!-- 作者 -->		
	     			<div>作者:<input value="${Article.author}" type="text" name="author" id="authorId" onblur="losefocus2()"onfocus="getfocus2()"/><br/><span class="jiaoyan" id="null_span2"></span></div>
	     			<!-- 简介 -->
	     			<div>简介:<input value="${Article.scan}" type="text" name="scan" id="scanId" onblur="losefocus3()"onfocus="getfocus3()"/><br/><span class="jiaoyan" id="null_span3"></span></div>
	     			<!-- 图片 -->
	     			<div>封面:<b>${Article.pName}</b><br><input type="file" id="photo"name="photo"></div><br/>
	     			<input type="hidden" value="${Article.pName}" name="oldname">
	     			<input type="hidden" value="${Article.finalPath}" name="oldpath">
	     			
	     		
	     		    <div>一级标题:<select name="first" id="first" onchange="loadsecond()" >
	     					<c:forEach items="${firstList}" var="info">
	     						<option>${info}</option>
	     					</c:forEach>
	     					</select>
	     			</div>
	     			<div>二级标题:<select name="second" id="second">
	     					<c:forEach items="${secondList}" var="info1">
	     						<option>${info1}</option>
	     					</c:forEach>
	     					</select><input type="button" value=添加位置 onclick="addposition()">
	     			</div> 
	     			<div>
	     				所在板块:<input type="text" id="bankuai" name="bankuai" value="${Article.bankuai}">
	     			</div> 	
	     			<div>是否上架:<select value="${Article.isSj}" name="isSj" id="isSjId" ><option > 是</option><option>否</option></select><br/><span class="jiaoyan" id="null_span4"></span></div>
	     			
	     			<div>轮番图简介一:<input value="${Article.sentence1}" type="text" name="s1" id="s1Id" onblur="losefocus5()" onfocus="getfocus5()" /><br/><span class="jiaoyan" id="null_span5"></span></div>
	     			<div>轮番图简介二:<input value="${Article.sentence2}" type="text" name="s2" id="s2Id" onblur="losefocus6()" onfocus="getfocus6()" /><br/><span class="jiaoyan" id="null_span6"></span></div>
	     			
	     			<div>内容:<script type="text/plain" id="myEditor" style="width:1000px;height:240px;">
    						${Article.context}
							</script>
					</div>
	     			<input value="${Article.id}" type="hidden" name="id" />
	     			
	     			<input type="submit" value="确定" style="width:60px; height:30px;margin:120px 50px;" class="Mysubmit" onclick="success()"/>
	     		</form>
     		</div>
     	</div>
     	
     </div>
     <script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('myEditor');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
    function insertHtml() {
        var value = prompt('插入html代码', '');
        um.execCommand('insertHtml', value)
    }
    function isFocus(){
        alert(um.isFocus())
    }
    function doBlur(){
        um.blur()
    }
    function createEditor() {
        enableBtn();
        um = UM.getEditor('myEditor');
    }
    function getAllHtml() {
        alert(UM.getEditor('myEditor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('myEditor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('myEditor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用umeditor')方法可以设置编辑器的内容");
        UM.getEditor('myEditor').setContent('欢迎使用umeditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UM.getEditor('myEditor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UM.getEditor('myEditor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UM.getEditor('myEditor').selection.getRange();
        range.select();
        var txt = UM.getEditor('myEditor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UM.getEditor('myEditor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UM.getEditor('myEditor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UM.getEditor('myEditor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UM.getEditor('myEditor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
   
   
</script>
  </body>
</html>
